<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
    String path = request.getContextPath();
    String baseBath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE html>
<html>
<head>
    <title>营销机会管理</title>
    <base href=<%=baseBath%>
          <%@include file="../common_css.jsp"%>
                  </head>
<body class="childrenBody">

<form class="layui-form" >
    <blockquote class="layui-elem-quote quoteBox">

        <form class="layui-form">
            <div class="layui-inline">
                <div class="layui-input-inline">
                    <input type="text" name="customerName"
                           class="layui-input
							searchVal" placeholder="客户名" />
                </div>
                <div class="layui-input-inline">
                    <select name="userId"  id="userId">
                        <option value="-1" >全部员工</option>

                    </select>
                </div>
                <div class="layui-input-inline">
                    <select name="state"  id="state">
                        <option value="-1" >全部处理状态</option>

                    </select>
                </div>
                <a class="layui-btn search_btn" data-type="reload"><i
                        class="layui-icon">&#xe615;</i> 搜索</a>
            </div>
        </form>

    </blockquote>
    <table id="saleChanceList" class="layui-table"  lay-filter="saleChances"></table>


    <!--操作-->
    <script id="saleChanceListBar" type="text/html">
        {{# if (d.handleState == 1) { }}
            <a class="layui-btn layui-btn-xs" id="process" lay-event="process">处理</a>
        {{# } else { }}
            <a href="javascript:;" class="layui-btn layui-btn-normal layui-btn-xs"  lay-event="info">详情</a>
        {{# } }}
    </script>

</form>
<script type="text/javascript">
    layui.use(['table','layer'],function(){
        var layer = parent.layer === undefined ? layui.layer : top.layer,
            $ = layui.jquery,
            table = layui.table;

        var  tableIns = table.render({
            elem: '#saleChanceList',
            url : 'cancelApply/findCancelApply',
            cellMinWidth : 95,
            page : true,
            height : "full-125",
            limits : [10,15,20,25],
            limit : 10,
            toolbar: "#toolbarDemo",
            id : "saleChanceListTable",
            method : 'post',
            cols : [[
                {field: "id", title:'编号',fixed:"true",width:80},
                {field:'orderId', title: '订单编号',templet:function (d){
                    return d.cusOrder.orderId;
                    }},
                {field:'title', title: '客户姓名',width: 100,templet: function(d){
                        return d.customer.name
                    }},
                {field: 'car', title: '订单车型',align:"center",templet:function (d){
                        return d.car.series+" "+d.car.model
                    }},
                {field: 'userName', title: '员工', align:'center',templet:function (d){
                        return d.customer.user.name
                    }},
                {field: 'stringHandleState',title: '处理状态',align: 'center'},
                {field: 'updateTime', title: '申请时间',  align:'center',templet:function (d){
                    return d.cusOrder.updateTime;
                    }},
                {title: '操作', templet:'#saleChanceListBar',fixed:"right",align:"center", minWidth:150}
            ]]
        });



        table.on('tool(saleChances)',function (obj) {
            var layEvent =obj.event;
            if(layEvent == 'process'){
                var title="退订处理";
                var url = "/cancelApply/toCancelProcess?id="+$(this).parent().parent().siblings(":first").children().text();
                layui.layer.open({
                    title:title,
                    type:2,
                    area:["700px","400px"],
                    maxmin:true,
                    content:url
                })
            }else {
                var title="退订详情";
                var url = "/cancelApply/toCancelProcess?id="+$(this).parent().parent().siblings(":first").children().text();
                layui.layer.open({
                    title:title,
                    type:2,
                    area:["700px","400px"],
                    maxmin:true,
                    content:url
                })
            }

        });



        $.post("user/findUser",function (res) {
            for(var i=0;i<res.length;i++){
                //绑定下拉框显示
                $("#userId").append("<option value=\""+res[i].id+"\"   >"+res[i].name+"</option>");
            }
            // 重新渲染下拉框内容
            layui.form.render("select");
        });
        $.post("dictionaries/findHandleState",function (res) {
            for(var i=0;i<res.length;i++) {
                $("#state").append("<option value=\"" + res[i].valueId + "\"   >" + res[i].valueName + "</option>");
            }
            // 重新渲染下拉框内容
            layui.form.render("select");
        });
        // 多条件搜索
        $(".search_btn").on("click",function () {
            table.reload("saleChanceListTable",{
                page:{
                    curr:1
                },
                where:{
                    customerName:$("input[name='customerName']").val(),// 客户名
                    userId:$("#userId").val(),// 客户名
                    state:$("#state").val()    //分配状态
                },
                url:'cancelApply/findCancelApplyConditional',
                contentType:"application/json"
            })
        });



    });

</script>
</body>
</html>